<?php
/**
 ***********************************************************************************************************************
 * 快递员app绑定巴枪的快递员基础资料获取
 * @author ldh 2017-6-20
 ***********************************************************************************************************************
 */
namespace soa\BasicInfo;

use soa\client;
use soa\partner\partnerCommon;

class scanCourier extends client
{
    public $service_url = 'http://pda.core.kuaidihelp.com/';

    protected $service_name = 'kuaidihelp_pda';

    /**
     *  用一个工号获取快递员巴枪数据(多个)
     * @param $brand
     * @param $cmCode
     * @return array
     */
    public function getByCmCode($brand, $cmCode)
    {
        if(empty($cmCode) || empty($brand)) {
            return [];
        }
        return $this->post('/v1/ScanCourier/getScanInfoByCmCode', ['brand'=>$brand,'cm_code'=>$cmCode]);
    }

    /**
     * 用多个工号获取快递员巴枪数据(多个)
     * @param $brand
     * @param $cmCodes
     * @return array
     */
    public function getByCmCodes($brand, $cmCodes)
    {
        if(empty($cmCodes) || empty($brand)) {
            return [];
        }
        return $this->post('/v1/ScanCourier/getScanInfoByCmCode', ['brand'=>$brand,'cm_codes'=>$cmCodes]);
    }

    /**
     * 用手机号获取快递员巴枪数据(单个)
     * 中通：switch = on
     * 其他品牌：valid = 1
     *
     * @param $brand
     * @param $mobile
     * @return array
     */
    public function getScanInfoByMobile($brand, $mobile)
    {
        if(empty($mobile) || empty($brand)) {
            return [];
        }
        return $this->post('/v1/ScanCourier/getScanInfoByMobile', ['brand'=>$brand,'cm_phone'=>$mobile]);
    }

    /**
     * 用手机号获取快递员巴枪数据(非禁用)(单个)
     * 中通：switch = on ,states = approve
     * 其他品牌：valid = 1 ，states = approved
     *
     * @param $brand
     * @param $mobile
     * @return array
     */
    public function getAccessInfoByMobile($brand, $mobile)
    {
        if(empty($mobile) || empty($brand)) {
            return [];
        }
        return $this->post('/v1/ScanCourier/getAccessInfoByMobile', ['brand'=>$brand,'cm_phone'=>$mobile]);
    }

    /**
     * 用手机号获取快递员巴枪数据(非禁用)(单个)(缓存)
     * 中通：switch = on ,states = approve
     * 其他品牌：valid = 1 ，states = approved
     *
     * @param $brand
     * @param $mobile
     * @return array
     */
    public function getAccessInfo($brand, $mobile)
    {
        if(empty($mobile) || empty($brand)) {
            return [];
        }
        return partnerCommon::getAccessInfo(['brand'=>$brand,'username'=>$mobile]);
    }

    /**
     * 用多个注册表id获取快递员巴枪数据(单个)
     * @param $cmId
     * @return array
     */
    public function getByCmId($brand, $cmId)
    {
        if(empty($cmId) || empty($brand)) {
            return [];
        }
        return $this->post('/v1/ScanCourier/getScanInfoByKey', ['brand'=>$brand,'cm_id'=>$cmId]);
    }

    /**
     * 用多个注册表id获取快递员巴枪数据(多个)
     * @param $cmIds
     * @return array
     */
    public function getByCmIds($brand, $cmIds)
    {
        if(empty($cmIds) || empty($brand)) {
            return [];
        }
        return $this->post('/v1/ScanCourier/getScanInfoByKey', ['brand'=>$brand,'cm_ids'=>$cmIds]);
    }
}